home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / LabelButtonBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  11KB  |  293 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  09/07/97    LAB    Fixed misspelling of descriptions. Removed background and foreground properties.
  8. //  08/19/98    LAB    Moved to GroupAWTAdditions folder.
  9.  
  10. /**
  11.  * BeanInfo for LabelButton.
  12.  *
  13.  */
  14. public class LabelButtonBeanInfo extends SimpleBeanInfo {
  15.  
  16.     /**
  17.      * Constructs a LabelButtonBeanInfo object.
  18.      */
  19.     public LabelButtonBeanInfo() {
  20.     }
  21.  
  22.     /**
  23.      * Gets a BeanInfo for the superclass of this bean.
  24.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  25.      */
  26.     public BeanInfo[] getAdditionalBeanInfo() {
  27.         try {
  28.             BeanInfo[] bi = new BeanInfo[1];
  29.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  30.             return bi;
  31.         }
  32.         catch (IntrospectionException e) { throw new Error(e.toString());}
  33.     }
  34.  
  35.     /**
  36.      * Gets the SymantecBeanDescriptor for this bean.
  37.      * @return an object of type SymantecBeanDescriptor
  38.      * @see symantec.itools.beans.SymantecBeanDescriptor
  39.      */
  40.     public BeanDescriptor getBeanDescriptor() {
  41.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  42.         String s=group.getString("GroupAWTAdditions"); 
  43.  
  44.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  45.         bd.setFolder(s);
  46.         bd.setWinHelp("0x123A6");
  47.  
  48.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  49.         s=conn.getString("ALIGN_LEFT"); 
  50.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  51.                                                 "%name%.ALIGN_LEFT",s));
  52.  
  53.         s=conn.getString("ALIGN_CENTERED"); 
  54.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  55.                                                 "%name%.ALIGN_CENTERED",s));
  56.  
  57.         s=conn.getString("ALIGN_RIGHT"); 
  58.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  59.                                                 "%name%.ALIGN_RIGHT",s));
  60.  
  61.         s=conn.getString("ALIGN_TOP"); 
  62.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  63.                                                 "%name%.ALIGN_TOP",s));
  64.  
  65.         s=conn.getString("ALIGN_BOTTOM"); 
  66.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  67.                                                 "%name%.ALIGN_BOTTOM",s));
  68.  
  69.  
  70.         bd.addAdditionalConnections(getAdditionalBeanInfo());
  71.  
  72.         return (BeanDescriptor) bd;
  73.     }
  74.  
  75.     /**
  76.      * Gets an image that may be used to visually represent this bean
  77.      * (in the toolbar, on a form, etc).
  78.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  79.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  80.      * @return an image for this bean, always color even if requested monochrome
  81.      * @see BeanInfo#ICON_MONO_16x16
  82.      * @see BeanInfo#ICON_COLOR_16x16
  83.      * @see BeanInfo#ICON_MONO_32x32
  84.      * @see BeanInfo#ICON_COLOR_32x32
  85.      */
  86.     public java.awt.Image getIcon(int iconKind) {
  87.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  88.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  89.             java.awt.Image img = loadImage("LabelButtonC16.gif");
  90.             return img;
  91.         }
  92.  
  93.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  94.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  95.             java.awt.Image img = loadImage("LabelButtonC32.gif");
  96.             return img;
  97.         }
  98.  
  99.         return null;
  100.     }
  101.  
  102.     /**
  103.      * Gets an array of descriptions of the methods used for "connections" by
  104.      * Visual CafΘ's Interaction Wizard.
  105.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  106.      * @return method descriptions for this bean
  107.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  108.      */
  109.     public MethodDescriptor[] getMethodDescriptors() {
  110.         Class[] args;
  111.         ConnectionDescriptor connection;
  112.         java.util.Vector connections;
  113.         java.util.Vector md = new java.util.Vector();
  114.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  115.  
  116.         try{
  117.             args = new Class[1];
  118.             args[0] = java.lang.String.class ;
  119.             MethodDescriptor setText = new MethodDescriptor(beanClass.getMethod("setText", args));
  120.  
  121.             connections = new java.util.Vector();
  122.             connection = new ConnectionDescriptor("input", "String", "",
  123.                                     "%name%.setText(%arg%);",
  124.                                     conn.getString("setText"));
  125.             connections.addElement(connection);
  126.  
  127.             setText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  128.             md.addElement(setText);
  129.         } catch (Exception e) { throw new Error("setText:: " + e.toString()); }
  130.  
  131.         try{
  132.             args = null;
  133.             MethodDescriptor getVerticalAlignStyle = new MethodDescriptor(beanClass.getMethod("getVerticalAlignStyle", args));
  134.  
  135.             connections = new java.util.Vector();
  136.             connection = new ConnectionDescriptor("output", "int", "",
  137.                                     "%name%.getVerticalAlignStyle()",
  138.                                     conn.getString("getVerticalAlignStyle"));
  139.             connections.addElement(connection);
  140.  
  141.             getVerticalAlignStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  142.             md.addElement(getVerticalAlignStyle);
  143.         } catch (Exception e) { throw new Error("getVerticalAlignStyle:: " + e.toString()); }
  144.  
  145.         try{
  146.             args = new Class[1];
  147.             args[0] = java.awt.Color.class ;
  148.             MethodDescriptor setTextColor = new MethodDescriptor(beanClass.getMethod("setTextColor", args));
  149.  
  150.             connections = new java.util.Vector();
  151.             connection = new ConnectionDescriptor("input", "Color", "",
  152.                                     "%name%.setTextColor(%arg%);",
  153.                                     conn.getString("setTextColorLBtn"));
  154.             connections.addElement(connection);
  155.  
  156.             setTextColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  157.             md.addElement(setTextColor);
  158.         } catch (Exception e) { throw new Error("setTextColor:: " + e.toString()); }
  159.  
  160.         try{
  161.             args = new Class[1];
  162.             args[0] = java.lang.Integer.TYPE ;
  163.             MethodDescriptor setAlignStyle = new MethodDescriptor(beanClass.getMethod("setAlignStyle", args));
  164.  
  165.             connections = new java.util.Vector();
  166.             connection = new ConnectionDescriptor("input", "int", "",
  167.                                     "%name%.setAlignStyle(%arg%);",
  168.                                     conn.getString("setAlignStyleLBtn"));
  169.             connections.addElement(connection);
  170.  
  171.             setAlignStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  172.             md.addElement(setAlignStyle);
  173.         } catch (Exception e) { throw new Error("setAlignStyle:: " + e.toString()); }
  174.  
  175.         try{
  176.             args = new Class[1];
  177.             args[0] = java.lang.Integer.TYPE ;
  178.             MethodDescriptor setVerticalAlignStyle = new MethodDescriptor(beanClass.getMethod("setVerticalAlignStyle", args));
  179.  
  180.             connections = new java.util.Vector();
  181.             connection = new ConnectionDescriptor("input", "int", "",
  182.                                     "%name%.setVerticalAlignStyle(%arg%);",
  183.                                     conn.getString("setVerticalAlignStyle"));
  184.             connections.addElement(connection);
  185.  
  186.             setVerticalAlignStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  187.             md.addElement(setVerticalAlignStyle);
  188.         } catch (Exception e) { throw new Error("setVerticalAlignStyle:: " + e.toString()); }
  189.  
  190.         try{
  191.             args = null;
  192.             MethodDescriptor getTextColor = new MethodDescriptor(beanClass.getMethod("getTextColor", args));
  193.  
  194.             connections = new java.util.Vector();
  195.             connection = new ConnectionDescriptor("output", "Color", "",
  196.                                     "%name%.getTextColor()",
  197.                                     conn.getString("getTextColorLBtn"));
  198.             connections.addElement(connection);
  199.  
  200.             getTextColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  201.             md.addElement(getTextColor);
  202.         } catch (Exception e) { throw new Error("getTextColor:: " + e.toString()); }
  203.  
  204.         try{
  205.             args = null;
  206.             MethodDescriptor getText = new MethodDescriptor(beanClass.getMethod("getText", args));
  207.  
  208.             connections = new java.util.Vector();
  209.             connection = new ConnectionDescriptor("output", "String", "",
  210.                                     "%name%.getText()",
  211.                                     conn.getString("getTextLBtn"));
  212.             connections.addElement(connection);
  213.  
  214.             getText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  215.             md.addElement(getText);
  216.         } catch (Exception e) { throw new Error("getText:: " + e.toString()); }
  217.  
  218.         try{
  219.             args = null;
  220.             MethodDescriptor getAlignStyle = new MethodDescriptor(beanClass.getMethod("getAlignStyle", args));
  221.  
  222.             connections = new java.util.Vector();
  223.             connection = new ConnectionDescriptor("output", "int", "",
  224.                                     "%name%.getAlignStyle()",
  225.                                     conn.getString("getAlignStyleLBtn"));
  226.             connections.addElement(connection);
  227.  
  228.             getAlignStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  229.             md.addElement(getAlignStyle);
  230.         } catch (Exception e) { throw new Error("getAlignStyle:: " + e.toString()); }
  231.  
  232.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  233.         md.copyInto(rv);
  234.  
  235.         return rv;
  236.     }
  237.  
  238.     /**
  239.      * Returns descriptions of this bean's properties.
  240.      */
  241.     public PropertyDescriptor[] getPropertyDescriptors() {
  242.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  243.  
  244.         try{
  245.         PropertyDescriptor defProperty = new PropertyDescriptor("text", beanClass);
  246.         defProperty.setBound(true);
  247.         defProperty.setConstrained(true);
  248.         defProperty.setDisplayName(prop.getString("text"));
  249.  
  250.         PropertyDescriptor textColor = new PropertyDescriptor("textColor", beanClass);
  251.         textColor.setBound(true);
  252.         textColor.setConstrained(true);
  253.         textColor.setDisplayName(prop.getString("textColor"));
  254.  
  255.         PropertyDescriptor alignStyle = new PropertyDescriptor("alignStyle", beanClass);
  256.         alignStyle.setBound(true);
  257.         alignStyle.setConstrained(true);
  258.         alignStyle.setDisplayName(prop.getString("alignStyle"));
  259.         alignStyle.setValue("ENUMERATION", "ALIGN_LEFT=0, ALIGN_CENTERED=1, ALIGN_RIGHT=2");
  260.  
  261.         PropertyDescriptor verticalAlignStyle = new PropertyDescriptor("verticalAlignStyle", beanClass);
  262.         verticalAlignStyle.setBound(true);
  263.         verticalAlignStyle.setConstrained(true);
  264.         verticalAlignStyle.setDisplayName(prop.getString("verticalAlignStyle"));
  265.         verticalAlignStyle.setValue("ENUMERATION", "ALIGN_TOP=0, ALIGN_CENTERED=1, ALIGN_BOTTOM=2");
  266.  
  267.         PropertyDescriptor background = new PropertyDescriptor("background", beanClass);
  268.         background.setHidden(true);
  269.  
  270.         PropertyDescriptor foreground = new PropertyDescriptor("foreground", beanClass);
  271.         foreground.setHidden(true);
  272.  
  273.         PropertyDescriptor[] rv = {
  274.             defProperty,
  275.             textColor,
  276.             alignStyle,
  277.             verticalAlignStyle,
  278.             background,
  279.             foreground};
  280.         return rv;
  281.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  282.     }
  283.  
  284.     /**
  285.      * Returns the index of the property expected to be changed most often by the designer.
  286.      */
  287.     public int getDefaultPropertyIndex() {
  288.         return 0;    //  the index for our default property is always 0
  289.     }
  290.  
  291.     private final static Class beanClass = LabelButton.class;
  292.  
  293.     }    //  end of class LabelButtonBeanInfo